<style lang="scss" scoped src="./index.component.scss"></style>
<template>
	<div class="container-index">
		<div class="name-index">
			index component
		</div>
		<app-sub class="comp-sub"></app-sub>
	</div>
</template>
<script lang="ts">
import { defineComponent, inject } from 'vue';
import AppSub from "@/app/view/index/sub/sub.component.vue";
import type { InnerMqService } from '@/app/rx/service/inner-mq.service';
import type { InnerMqClient } from '@/app/rx/client/inner-mq.client';
import { Topic } from "@/app/rx/topic";

export default defineComponent({
	name: 'app-index',
	components: {
		AppSub,
	},
	setup() {
		const innerMqService = inject('innerMqService') as InnerMqService;
		let client!: InnerMqClient;
		return {
			innerMqService, client,
		}
	},
	created() {
		this.client = this.innerMqService.createClient();
		this.client.sub(Topic.MY_TP_1, (res: string) => {
			console.log(res);
		});
	},
	beforeUnmount() {
		this.innerMqService.destroyClient(this.client);
	},
});
</script>
